Skip to content

Conversation

@Aiiaiiio
Copy link
Collaborator

@Aiiaiiio Aiiaiiio commented Oct 2, 2025

This is a quick fix to convert the full source paths to relative ones in log files. Saves a bit of spaces and prevents a security risk (leaking CI paths into logs).

I understand that the solution is a bit wonky. I've looked at other possibilities and found this the least bad. Suggestions welcome.

Signed-off-by: Tamás Bari <[email protected]>
CMakeLists.txt Outdated

get_git_head_revision(GIT_REFSPEC GIT_SHA1)

add_definitions(-DSOURCE_ROOT="${CMAKE_SOURCE_DIR}")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please no
this should be properly defined in config.h.in
if you work on the code, and have this global define you cannot figure out where it is coming from
in addition, we should always use the cmake so-called target APIs
https://cmake.org/cmake/help/latest/command/target_compile_definitions.html for example

Comment on lines 119 to 137
QString msg = qFormatLogMessage(type, ctx, message);

// We want to change the full path of the source file to relative,
// to reduce log size and also, to not leak paths into logs.
// To help with this, there is a placeholder in the message pattern
// for the file path ("<file-path-here>").
QString filePath;
if (ctx.file != nullptr) {
static const QString projectRoot = QStringLiteral(SOURCE_ROOT);

filePath = QFileInfo(QString::fromLocal8Bit(ctx.file)).absoluteFilePath();
if (filePath.startsWith(projectRoot)) {
filePath = filePath.mid(projectRoot.size() + 1);
}
}

static const QString filePathPlaceholder = "<file-path-here>";
msg.replace(filePathPlaceholder, filePath);

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am really concerned about the performance implication of that change
we already are a bit slow when printing logs
maybe you could use a hash map to have a quick mapping from absolute paths to relative ones and just add this info somewhere in the log line

Instead of trying to convert them to relative paths.

Signed-off-by: Tamás Bari <[email protected]>
@Aiiaiiio Aiiaiiio requested a review from mgallien October 2, 2025 13:30
@sonarqubecloud
Copy link

sonarqubecloud bot commented Oct 2, 2025

Quality Gate Failed Quality Gate failed

Failed conditions
11 New Code Smells (required ≤ 0)
D Maintainability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

#include <QStringList>
#include <QtGlobal>
#include <QTextCodec>
#include <QtGlobal>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this change really needed ?

Comment on lines 64 to 65
namespace OCC
{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please revert
current style is
namespace OCC {

{
if (_logstream)
{
if (_logstream) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please split code style fixes into a separate commit
makes it easier to selectively revert or test changes while keeping code style improvements

QFile file(dir);
file.setPermissions(perm);

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

int maxNumber = -1;
const auto collidingFileNames = dir.entryList({QStringLiteral("%1.*").arg(newLogName)}, QDir::Files, QDir::Name);
for(const auto &fileName : collidingFileNames) {
for (const auto &fileName : collidingFileNames) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

auto previousLog = QString{};
switch (type)
{
switch (type) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

{
qSetMessagePattern(QStringLiteral("%{time yyyy-MM-dd hh:mm:ss:zzz} [ %{type} %{category} %{file}:%{line} "
"]%{if-debug}\t[ %{function} ]%{endif}:\t%{message}"));
qSetMessagePattern(QStringLiteral("%{time yyyy-MM-dd hh:mm:ss:zzz} [%{type} %{category}]:\t%{message}; %{function} %{if-debug}%{file}%{endif}:%{line}"));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please do not change the order ?
omitting the file may save some characters but we should keep the order unchanged to not break possibly existing parsers for the logs

{
static long long int linesCounter = 0;
const auto &msg = qFormatLogMessage(type, ctx, message);
QString msg = qFormatLogMessage(type, ctx, message);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
QString msg = qFormatLogMessage(type, ctx, message);
const auto msg = qFormatLogMessage(type, ctx, message);

Comment on lines 149 to 150
if (_doFileFlush || _linesCounter >= MaxLogLinesBeforeFlush || type == QtMsgType::QtWarningMsg || type == QtMsgType::QtCriticalMsg
|| type == QtMsgType::QtFatalMsg) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment (code style)

Copy link
Member

@nilsding nilsding left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change won't resolve the leakage of the complete build path though.

The logger macros (and apparently Qt's old SLOT() macro as well?) embed __FILE__ at compile time, so the full path still ends up in the built binaries:

% strings -n 30 ./bin/nextclouddev | egrep '^/.+/desktop/src/gui/' | sort -u | head -n10
/home/jyrki/src/nextcloud/desktop/src/gui/accountmanager.cpp
/home/jyrki/src/nextcloud/desktop/src/gui/accountsettings.cpp
/home/jyrki/src/nextcloud/desktop/src/gui/accountsetupcommandlinemanager.cpp
/home/jyrki/src/nextcloud/desktop/src/gui/accountsetupfromcommandlinejob.cpp
/home/jyrki/src/nextcloud/desktop/src/gui/accountstate.cpp
/home/jyrki/src/nextcloud/desktop/src/gui/addcertificatedialog.cpp
/home/jyrki/src/nextcloud/desktop/src/gui/application.cpp
/home/jyrki/src/nextcloud/desktop/src/gui/application.cpp:633
/home/jyrki/src/nextcloud/desktop/src/gui/callstatechecker.cpp
/home/jyrki/src/nextcloud/desktop/src/gui/caseclashfilenamedialog.cpp

@Aiiaiiio
Copy link
Collaborator Author

Aiiaiiio commented Oct 6, 2025

I feel resistance to to change the logging pattern. Which I can understand, very minor benefit to it. The security part is somewhat important, but this PR wasn't really about that. Plus what @nilsding found suggests that we should go about it very differently. Should we just ditch this PR?

Rello and others added 16 commits October 14, 2025 14:55
will enable to dynamically fetch the list of files inside a folder

for now, only basic infrastructure plugging into CfApi is there

Signed-off-by: Matthieu Gallien <[email protected]>
will enable to dynamically fetch the list of files inside a folder

for now, only basic infrastructure plugging into CfApi is there

Signed-off-by: Matthieu Gallien <[email protected]>
will prevent continuous loop of trying to populated the root folder on
loop

Signed-off-by: Matthieu Gallien <[email protected]>
Signed-off-by: Matthieu Gallien <[email protected]>
will make all folders be initially skipped by cerating an entry into a
new type of blacklist

upon access by the users they will be removed from this list and synced
as normal folders

that is a kid of automatic selective sync mechanism (but still creating
the folders that are skipped)

that would allow the user to know them and access them triggering the
dynamic fetching mechanism

Signed-off-by: Matthieu Gallien <[email protected]>
should make the logic much more reliable

Signed-off-by: Matthieu Gallien <[email protected]>
should enable proper type handling for virtual directories (i.e.
on-demand populated folders)

Signed-off-by: Matthieu Gallien <[email protected]>
after having populated the entries in a on-demand folder, update its
type in database to ensure updated state

only virtual folders have the on-demand feature enabled and that should
happen only once as we always fully populated a folder

Signed-off-by: Matthieu Gallien <[email protected]>
do not forget that a virtual folder is being also a folder

Signed-off-by: Matthieu Gallien <[email protected]>
when a folder is being hydrated (is no longer virtual), let's change the
DB record type to be an usual folder part of the normal synchronization

Signed-off-by: Matthieu Gallien <[email protected]>
dependabot bot and others added 26 commits October 14, 2025 14:55
Bumps [cpp-linter/cpp-linter-action](https://github.com/cpp-linter/cpp-linter-action) from 2.16.4 to 2.16.5.
- [Release notes](https://github.com/cpp-linter/cpp-linter-action/releases)
- [Commits](cpp-linter/cpp-linter-action@7dacd91...b7fbdde)

---
updated-dependencies:
- dependency-name: cpp-linter/cpp-linter-action
  dependency-version: 2.16.5
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
… Account

With this change some warnings from QObject like these are gone now:

    QObject: Cannot create children for a parent that is in a different thread.

I suspect this might have been causing some "random" crashes during
normal usage as well.  QNAMs are supposed to be used from the same
thread they were created in, which (as far as I could tell anyway) isn't
the case within async image providers...

This change is similar to how the `ImageResponse` class inside
`src/gui/tray/usermodel.cpp` fetches a remote resource.

Signed-off-by: Jyrki Gadinger <[email protected]>
…ialogs

Changed HTML anchor attribute delimiters from single quotes to double quotes
in conflictdialog.cpp and caseclashfilenamedialog.cpp to properly handle
file paths containing single quote characters.

Fixes issue where clicking links for files with single quotes in their path
would fail due to malformed HTML.

Signed-off-by: GitHub Copilot <[email protected]>

Co-authored-by: Rello <[email protected]>
Use Utility::escape() to HTML-escape file URLs before embedding them in
anchor tags. This ensures both single quotes and double quotes (and other
HTML special characters) are properly handled.

The toHtmlEscaped() function converts:
- ' to &#39;
- " to &quot;
- & to &amp;
- < to &lt;
- > to &gt;

This fixes the issue where changing from single to double quote delimiters
would break with double quotes instead.

Signed-off-by: GitHub Copilot <[email protected]>

Co-authored-by: nilsding <[email protected]>
In #8860 I noticed that the "insufficient memory error" message is
logged if the last error was anything but `ERROR_INSUFFICIENT_BUFFER`

- fix comparison operator
- format Windows error codes with a hex code and message

Signed-off-by: Jyrki Gadinger <[email protected]>
Reported at Transifex

Signed-off-by: rakekniven <[email protected]>
Adjust .gitignore to accept a file with 'build' in the name.

Signed-off-by: Camila Ayres <[email protected]>
Signed-off-by: Tamás Bari <[email protected]>
This reverts commit 74f0d90efac5c4c3174bec8444efda8ed2295aa0.
This reverts commit c92f947bda408693f239cd2469262477677e0033.
@Aiiaiiio
Copy link
Collaborator Author

This change won't resolve the leakage of the complete build path though.

The logger macros (and apparently Qt's old SLOT() macro as well?) embed __FILE__ at compile time, so the full path still ends up in the built binaries:

% strings -n 30 ./bin/nextclouddev | egrep '^/.+/desktop/src/gui/' | sort -u | head -n10
/home/jyrki/src/nextcloud/desktop/src/gui/accountmanager.cpp
/home/jyrki/src/nextcloud/desktop/src/gui/accountsettings.cpp
/home/jyrki/src/nextcloud/desktop/src/gui/accountsetupcommandlinemanager.cpp
/home/jyrki/src/nextcloud/desktop/src/gui/accountsetupfromcommandlinejob.cpp
/home/jyrki/src/nextcloud/desktop/src/gui/accountstate.cpp
/home/jyrki/src/nextcloud/desktop/src/gui/addcertificatedialog.cpp
/home/jyrki/src/nextcloud/desktop/src/gui/application.cpp
/home/jyrki/src/nextcloud/desktop/src/gui/application.cpp:633
/home/jyrki/src/nextcloud/desktop/src/gui/callstatechecker.cpp
/home/jyrki/src/nextcloud/desktop/src/gui/caseclashfilenamedialog.cpp

So, I reverted my previous changes. Instead I introduced the -fmacro-prefix-map compile option. This removes the absolute paths from the release build. Now I only have:

> strings /home/tbari/work/nextcloud/desktop/build/Desktop_Qt_6_9_2-Release/bin/nextcloud  | grep tbari
/home/tbari/Qt/6.9.2/gcc_64/lib:/home/tbari/work/nextcloud/desktop/build/Desktop_Qt_6_9_2-Release/bin:/home/tbari/Qt/6.9.2/gcc_64/lib64:

Which is coming from the RUNPATHs. That will be taken care of by the deploy tools.
This options doesn't exist with MSVC, but afaik the default behaviour is to use relative paths there, so we will see... testing now.

@github-actions
Copy link

Artifact containing the AppImage: nextcloud-appimage-pr-8823.zip

Digest: sha256:2df7868115e5877c1138c611c63d38d532a7457ef9f26b3f7f004e79696c4541

To test this change/fix you can download the above artifact file, unzip it, and run it.

Please make sure to quit your existing Nextcloud app and backup your data.

@github-actions
Copy link

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

(If you believe you should not receive this message, you can add yourself to the blocklist.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.